package slu.appli.string.format;

public class StringFormatter {
	public static String formaElapse(long elapse) {
		long sec = elapse / 1000;
		long min = sec / 60;
		long hour = min / 60;
		long days = hour / 24;
		long ms = elapse - (sec * 1000);
		sec = sec - (min * 60);
		min = min - (hour * 60);
		hour = hour - (days * 24);
		if (days != 0) return String.format("%d:%02d:%02d:%02d.%03d", days, hour, min, sec, ms);
		else if (hour != 0) return String.format("%02d:%02d:%02d.%03d", hour, min, sec, ms);
		else return String.format("%02d:%02d.%03d", min, sec, ms);
	}
	public static String formaElapse(int elapse) {
		long sec = elapse;
		long min = sec / 60;
		long hour = min / 60;
		long days = hour / 24;
		sec = sec - (min * 60);
		min = min - (hour * 60);
		hour = hour - (days * 24);
		if (days != 0) return String.format("%d %02d:%02d:%02d", days, hour, min, sec);
		else if (hour != 0) return String.format("%02d:%02d:%02d", hour, min, sec);
		else return String.format("%02d:%02d", min, sec);
	}
}
